package com.ssy.lingxi.purchase.api.enums.onlinebidding;

import com.ssy.lingxi.common.language.LanguageHolder;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 *采购报价外部流程记录枚举- 供应商竞价报价
 */
public enum OnlineBiddingExternalWorkStateEnum {
    CANCEL(-1, "已作废"),
    COMPLETE(99, "已完成"),
    STAY_SIGNUP_BIDDING(2, "待竞价报名"),
    STAY_EXAMINE_SIGNUP_BIDDING(3, "待审核竞价报名"),
    SIGNUP_BIDDING_NOT(4, "竞价报名审核不通过"),
    STAY_BIDDING(5, "待竞价"),
    BIDDING_CONFIRM_RETURN(6, "待确认竞价结果"),
    SIGNUP_BIDDING_PASS(7, "竞价报名审核通过"),
    ;

    private Integer state;
    private String name;

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public String getName() {
        return LanguageHolder.getName(this.getClass(), this.state);
    }

    public void setName(String name) {
        this.name = name;
    }

    OnlineBiddingExternalWorkStateEnum(Integer state, String name) {
        this.state = state;
        this.name = name;
    }

    public static String getName(Integer state){
        OnlineBiddingExternalWorkStateEnum workEnum = Arrays.stream(OnlineBiddingExternalWorkStateEnum.values()).filter(v -> v.getState().equals(state)).findAny().orElse(null);
        return null == workEnum ? "" : LanguageHolder.getName(OnlineBiddingExternalWorkStateEnum.class, workEnum.getState());
    }

    /**
     * 枚举值集合
     * @return
     */
    public static List<Integer> getCodes(){
        return Arrays.stream(OnlineBiddingExternalWorkStateEnum.values()).map(OnlineBiddingExternalWorkStateEnum::getState).collect(Collectors.toList());
    }
}
